/**
 * <p>Title: CommentsDao.java</p>
 * <p>Description: DoNotes</p>
 * @author WangJun
 * @date 2009/11/25 14:09:38
 * @version 1.0
 */
package net.donotes.blog.dao;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import net.donotes.blog.pojo.Comment;
import net.donotes.util.dao.PMF;

/**
 * @author WangJun
 *
 */
public class CommentDao {
	/**
	 * Title: addComment
	 * @param comment
	 */
	public void addComment(Comment comment) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
        try {
            pm.makePersistent(comment);
        } finally {
          //  pm.close();
        }
	}
	
	/**
	 * Title: delComment
	 * @param comment
	 */
	public void delComment(Comment comment) {
		
	}
	
	/**
	 * Title: getComment
	 * @param comment
	 * @return
	 */
	public Comment getComment(Comment comment) {
		return null;
	}
	
	/**
	 * Title: listComment
	 * @param comment
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Comment> listComment(Long id) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(Comment.class);
	    query.setFilter("postId == idParam");
		query.setOrdering("createDate desc");
		query.declareParameters("Long idParam");

		List<Comment> resultes = (List<Comment>)query.execute(id);
		return resultes;
	}

	/**
	 * Title: updComment
	 * @param comment
	 */
	public void updComment(Comment comment) {
		
	}	
}